home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / LineBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  192 lines

  1. package symantec.itools.awt.shape;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  07/31/97    LAB    Created and checked in.
  8. //  09/07/97    LAB    Removed background and font as properties (Addresses Mac Bug #7698).
  9. //  08/19/98    LAB    Removed from ToolBar.
  10.  
  11. /**
  12.  * BeanInfo for Line.
  13.  *
  14.  */
  15.  
  16. public class LineBeanInfo extends SimpleBeanInfo {
  17.  
  18.     /**
  19.      * Constructs a LineBeanInfo object.
  20.      */
  21.     public LineBeanInfo() {
  22.     }
  23.  
  24.     /**
  25.      * Gets a BeanInfo for the superclass of this bean.
  26.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  27.      */
  28.     public BeanInfo[] getAdditionalBeanInfo() {
  29.         try {
  30.             BeanInfo[] bi = new BeanInfo[1];
  31.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  32.             return bi;
  33.         }
  34.         catch (IntrospectionException e) { throw new Error(e.toString());}
  35.     }
  36.  
  37.     /**
  38.      * Gets the SymantecBeanDescriptor for this bean.
  39.      * @return an object of type SymantecBeanDescriptor
  40.      * @see symantec.itools.beans.SymantecBeanDescriptor
  41.      */
  42.     public BeanDescriptor getBeanDescriptor() {
  43.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  44.         String s=group.getString("GroupShape"); 
  45.  
  46.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  47.         bd.setFolder(s);
  48.  
  49.         return (BeanDescriptor) bd;
  50.     }
  51.  
  52.     /**
  53.      * Gets an image that may be used to visually represent this bean
  54.      * (in the toolbar, on a form, etc).
  55.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  56.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  57.      * @return an image for this bean, always color even if requested monochrome
  58.      * @see BeanInfo#ICON_MONO_16x16
  59.      * @see BeanInfo#ICON_COLOR_16x16
  60.      * @see BeanInfo#ICON_MONO_32x32
  61.      * @see BeanInfo#ICON_COLOR_32x32
  62.      */
  63.     public java.awt.Image getIcon(int iconKind) {
  64.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  65.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  66.             java.awt.Image img = loadImage("LineC16.gif");
  67.             return img;
  68.         }
  69.  
  70.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  71.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  72.             java.awt.Image img = loadImage("LineC32.gif");
  73.             return img;
  74.         }
  75.  
  76.         return null;
  77.     }
  78.  
  79.     /**
  80.      * Gets an array of descriptions of the methods used for "connections" by
  81.      * Visual CafΘ's Interaction Wizard.
  82.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  83.      * @return method descriptions for this bean
  84.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  85.      */
  86.     public MethodDescriptor[] getMethodDescriptors() {
  87.         Class[] args;
  88.         ConnectionDescriptor connection;
  89.         java.util.Vector connections;
  90.         java.util.Vector md = new java.util.Vector();
  91.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  92.  
  93.         try{
  94.             args = new Class[1];
  95.             args[0] = java.lang.Boolean.TYPE ;
  96.             MethodDescriptor setPositiveSlope = new MethodDescriptor(beanClass.getMethod("setPositiveSlope", args));
  97.  
  98.             connections = new java.util.Vector();
  99.             connection = new ConnectionDescriptor("input", "boolean", "",
  100.                                     "%name%.setPositiveSlope(%arg%);",
  101.                                     conn.getString("setPositiveSlope"));
  102.             connections.addElement(connection);
  103.  
  104.             setPositiveSlope.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  105.             md.addElement(setPositiveSlope);
  106.         } catch (Exception e) { throw new Error("setPositiveSlope:: " + e.toString()); }
  107.  
  108.         try{
  109.             args = null;
  110.             MethodDescriptor isPositiveSlope = new MethodDescriptor(beanClass.getMethod("isPositiveSlope", args));
  111.  
  112.             connections = new java.util.Vector();
  113.             connection = new ConnectionDescriptor("output", "boolean", "",
  114.                                     "%name%.isPositiveSlope()",
  115.                                     conn.getString("isPositiveSlope"));
  116.             connections.addElement(connection);
  117.  
  118.             isPositiveSlope.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  119.             md.addElement(isPositiveSlope);
  120.         } catch (Exception e) { throw new Error("isPositiveSlope:: " + e.toString()); }
  121.  
  122.         try{
  123.             args = new Class[1];
  124.             args[0] = java.lang.Integer.TYPE ;
  125.             MethodDescriptor setLineThickness = new MethodDescriptor(beanClass.getMethod("setLineThickness", args));
  126.  
  127.             connections = new java.util.Vector();
  128.             connection = new ConnectionDescriptor("input", "int", "",
  129.                                     "%name%.setLineThickness(%arg%);",
  130.                                     conn.getString("setLineThickness"));
  131.             connections.addElement(connection);
  132.  
  133.             setLineThickness.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  134.             md.addElement(setLineThickness);
  135.         } catch (Exception e) { throw new Error("setLineThickness:: " + e.toString()); }
  136.  
  137.         try{
  138.             args = null;
  139.             MethodDescriptor getLineThickness = new MethodDescriptor(beanClass.getMethod("getLineThickness", args));
  140.  
  141.             connections = new java.util.Vector();
  142.             connection = new ConnectionDescriptor("output", "int", "",
  143.                                     "%name%.getLineThickness()",
  144.                                     conn.getString("getLineThickness"));
  145.             connections.addElement(connection);
  146.  
  147.             getLineThickness.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  148.             md.addElement(getLineThickness);
  149.         } catch (Exception e) { throw new Error("getLineThickness:: " + e.toString()); }
  150.  
  151.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  152.         md.copyInto(rv);
  153.  
  154.         return rv;
  155.     }
  156.  
  157.     /**
  158.      * Returns descriptions of this bean's properties.
  159.      */
  160.     public PropertyDescriptor[] getPropertyDescriptors() {
  161.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  162.  
  163.         try{
  164.         PropertyDescriptor positiveSlope = new PropertyDescriptor("positiveSlope", beanClass);
  165.         positiveSlope.setBound(true);
  166.         positiveSlope.setConstrained(true);
  167.         positiveSlope.setDisplayName(prop.getString("positiveSlope"));
  168.  
  169.         PropertyDescriptor lineThickness = new PropertyDescriptor("lineThickness", beanClass);
  170.         lineThickness.setBound(true);
  171.         lineThickness.setConstrained(true);
  172.         lineThickness.setDisplayName(prop.getString("lineThickness"));
  173.  
  174.         PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
  175.         background.setHidden(true);
  176.  
  177.         PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
  178.         font.setHidden(true);
  179.  
  180.         PropertyDescriptor[] rv = {
  181.             positiveSlope,
  182.             lineThickness,
  183.             background,
  184.             font};
  185.  
  186.         return rv;
  187.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  188.     }
  189.  
  190.     private final static Class beanClass = Line.class;
  191.  
  192.     }    //  end of class LineBeanInfo